home *** CD-ROM | disk | FTP | other *** search
- unit mlePropertyInfo;
-
- interface
-
- uses
- DB, DBTables, dpoBase;
-
- type
- TPropertyInfo = class
- private
- FPropertyName: string;
- protected
- Field: TField;
- function GetDatatype: TFieldType;
- function GetSize: Integer;
- procedure SetPropertyName(aValue: string);
- public
- Instance: TDataObject;
- function GetValue: Variant;
- function AsString: string;
- property DataType: TFieldType read GetDataType;
- property PropertyName: string read FPropertyName write SetPropertyName;
- property Size: Integer read GetSize;
- end;
-
- implementation
-
- uses
- SysUtils;
-
- { TPropertyInfo }
-
- function TPropertyInfo.AsString: string;
- begin
- case Datatype of
- ftCurrency:
- Result := FormatFloat('0.00', GetValue);
- ftTime:
- Result := FormatDateTime(ShortTimeFormat, GetValue);
- else
- Result := GetValue;
- end;
- end;
-
- function TPropertyInfo.GetDatatype: TFieldType;
- begin
- Result := Field.DataType;
- end;
-
- function TPropertyInfo.GetSize: Integer;
- begin
- Result := Field.Size;
- end;
-
- function TPropertyInfo.GetValue: Variant;
- begin
- Result := Field.AsVariant;
- end;
-
- procedure TPropertyInfo.SetPropertyName(aValue: string);
- begin
- if FPropertyName <> aValue then
- begin
- FPropertyName := aValue;
- Field := Instance.PropertyByName(PropertyName);
- end;
- end;
-
- end.
-